#!/usr/bin/perl
use CGI qw(:standard);
use DBI;


my $cgi = new CGI;
my $v = $cgi->param('v') ;
#$v = "1357652603:67289:0:17:1905:1:15:1900:2:20:1900:3:19:1980:4:20:1900:5:18:1900:";
print $cgi->header('application/json');


my $dsn = "dbi:mysql:mamaison:127.0.0.1:3306";
my $dbh = DBI->connect($dsn, 'root', '');


          my @result = split(/  | |;|:/,$v);
          my $i=-5;
my $query = "insert ignore into log(`date`,`c0` ,`c0target` ,`c0curtemp` , `c1` ,`c1target` ,`c1curtemp` , `c2` ,`c2target` ,`c2curtemp` , `c3` ,`c3target` ,`c3curtemp`,
	`c4` ,`c4target` ,`c4curtemp`, `c5` ,`c5target` ,`c5curtemp`)
        values(from_unixtime(floor($result[$i+5]/60)*60-3600),
'$result[$i+7]','$result[$i+8]',$result[$i+9]/100,
'$result[$i+10]','$result[$i+11]',$result[$i+12]/100,
'$result[$i+13]','$result[$i+14]',$result[$i+15]/100,
'$result[$i+16]','$result[$i+17]',$result[$i+18]/100,
'$result[$i+19]','$result[$i+20]',$result[$i+21]/100,
'$result[$i+22]','$result[$i+23]',$result[$i+24]/100)";
        print  $query."\n";
        $dbh->do($query);

print ;

